package com.matt.controller.api.web;

import com.matt.domain.Attachment;
import com.matt.foundation.model.StatusResponse;
import com.matt.foundation.query.AttachmentQuery;
import com.matt.service.AttachmentService;
import com.matt.remoteCall.SsoCallService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.*;

/**
 * *********************
 * description:附件控制器
 * Created by Ron
 * from com.matt
 * on 2018/6/26 0026.
 * **********************
 */
@RestController
@RequestMapping("/web/attachment")
@Api(tags = "CRM - 附件")
public class AttachmentController {

    @Autowired
    private AttachmentService attachmentService;
    @Autowired
    private SsoCallService ssoCallService;

    /**
     * 附件分页查询
     *
     * @param attachmentQuery
     * @param pageable
     * @return
     */
    @GetMapping(value = "/page")
    @ResponseBody
    public StatusResponse leadsByInfo(AttachmentQuery attachmentQuery, Pageable pageable) {
        // Page<Leads> page = leadsService.getPages(ticket,leadsQuery, pageable);
        Page<Attachment> page = attachmentService.findPage(attachmentQuery, pageable);
        return StatusResponse.success(page);
    }

    @PostMapping(value = "/add")
    public StatusResponse add(@RequestHeader String ticket, Attachment attachment) {
        return StatusResponse.success(attachmentService.save(ticket, attachment));
    }

}
